package com.janko.springbootbase.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.janko.springbootbase.entity.BaseUser;
import com.janko.springbootbase.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class BaseUserController {

    @Autowired
    UserService userService;

    @RequestMapping("/page")
    public Object selectPage(){
        Page page=new Page(1,10);          //1表示当前页，而10表示每页的显示显示的条目数
        page = userService.selectUserPage(page, "0");
        return page;
    }

    /**
     * RestFul格式的接口开发
     * @param uid
     * @return
     */
    @RequestMapping("/login/{uid}")
    public BaseUser login(@PathVariable int uid){
        BaseUser baseUser =userService.login(uid);
        return baseUser;
    }

    @RequestMapping("/getAll/{uid}")
    public java.util.List<BaseUser> getAll(@PathVariable int uid) {
        return userService.getAll();
    }
}
